<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" lang="zh-CN" xml:lang="zh-CN">
<head><meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
    <title>6.28. Bzip2-1.0.3</title>
    <link rel="stylesheet" href="../stylesheets/lfs.css" type="text/css" />
    <link rel="stylesheet" href="../stylesheets/lfs-print.css" type="text/css" media="print" />
<script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?d286c55b63a3c54a1e43d10d4c203e75"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
</head>
  <body id="lfs" class="6.2">
    <div class="navheader">
      <div class="headertitles">
        <h4>Linux From Scratch - 版本 6.2</h4>
        <h3>第六章 安装系统基础软件</h3>
      </div>
      <ul class="headerlinks">
        <li class="prev">
          <a accesskey="p" href="bash.html" title="Bash-3.1">后退</a>
          <p>Bash-3.1</p>
        </li>
        <li class="next">
          <a accesskey="n" href="diffutils.html" title="Diffutils-2.8.1">前进</a>
          <p>Diffutils-2.8.1</p>
        </li>
        <li class="up"><a accesskey="u" href="chapter06.html" title="第六章 安装系统基础软件">上一级</a></li>
        <li class="home"><a accesskey="h" href="../index.html" title="Linux From Scratch - 版本 6.2">首页</a></li>
      </ul>
    </div>
    <div class="wrap">
      <div class="titlepage">
        <h1 class="sect1">6.28. Bzip2-1.0.3</h1>
      </div>
      <div class="package">
        <p>Bzip2 包含了对文件进行压缩和解压缩的工具，对于文本文件，<span><strong class="command">bzip2</strong></span> 比传统的 <span><strong class="command">gzip</strong></span> 拥有更高压缩比。</p>
        <div class="segmentedlist">
          <div class="seglistitem">
            <div class="seg">
              <strong><span class="segtitle">预计编译时间：</span></strong> <span class="seg">少于 0.1 SBU</span>
            </div>
            <div class="seg">
              <strong><span class="segtitle">所需磁盘空间：</span></strong> <span class="seg">5.3 MB</span>
            </div>
          </div>
        </div>
      </div>
      <div class="installation">
        <div class="titlepage">
          <h2 class="sect2">6.28.1. 安装 Bzip2</h2>
        </div>
        <p>下面的补丁可以为这个软件包安装相应的文档：</p>
        <pre class="userinput"><kbd class="command">patch -Np1 -i ../bzip2-1.0.3-install_docs-1.patch</kbd></pre>
        <p> <span><strong class="command">bzgrep</strong></span> 命令并不将传递给它的文件名中的 '|' 和 '&' 进行转义，这就会允许别有用心的用户执行任意命令。下面的补丁可以解决这个问题：</p>
        <pre class="userinput"><kbd class="command">patch -Np1 -i ../bzip2-1.0.3-bzgrep_security-1.patch</kbd></pre>
        <p> <span><strong class="command">bzdiff</strong></span> 脚本仍然会使用原来的 <span><strong class="command">tempfile</strong></span> 程序。可以使用 <span><strong class="command">mktemp</strong></span> 来替换：</p>
        <pre class="userinput"><kbd class="command">sed -i 's@tempfile -d /tmp -p bz@mktemp -p /tmp@' bzdiff</kbd></pre>
        <p>为编译 Bzip2 做准备：</p>
        <pre class="userinput"><kbd class="command">make -f Makefile-libbz2_so
make clean</kbd></pre>
        <div class="variablelist">
          <p class="title">
            <b>make 参数的含义：</b></p>
          <dl>
            <dt>
              <span class="term"><em class="parameter"><tt>-f
              Makefile-libbz2_so</tt></em></span>
            </dt>
            <dd>
              <p>这会采用一个另外一个 <tt class="filename">Makefile</tt> 来编译 Bzip2，也就是这里的 Makefile-libbz2_so 文件，它创建一个动态链接库 <tt class="filename">libbz2.so</tt> ，然后把Bzip2的工具都链接到这个库上。</p>
            </dd>
          </dl>
        </div>
        <p>编译并测试软件包：</p>
        <pre class="userinput"><kbd class="command">make</kbd></pre>
        <p>如果重新安装Bzip2，必须首先执行 <strong class="userinput"><tt>rm -vf
          /usr/bin/bz*</tt></strong> ，否则下面的 <span><strong class="command">make install</strong></span> 会出错。</p>
        <p>安装Bzip2：</p>
        <pre class="userinput"><kbd class="command">make install</kbd></pre>
        <p>把 <span><strong class="command">bzip2</strong></span> 二进制共享库拷贝到 <tt class="filename">/bin</tt> 目录，创建必要的符号链接，再做一些清理工作：</p>
        <pre class="userinput"><kbd class="command">cp -v bzip2-shared /bin/bzip2
cp -av libbz2.so* /lib
ln -sv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so
rm -v /usr/bin/{bunzip2,bzcat,bzip2}
ln -sv bzip2 /bin/bunzip2
ln -sv bzip2 /bin/bzcat</kbd></pre>
      </div>
      <div class="content">
        <div class="titlepage">
          <a id="contents-bzip2" name="contents-bzip2"></a>
          <h2 class="sect2">6.28.2. Bzip2 的内容</h2>
        </div>
        <div class="segmentedlist">
          <div class="seglistitem">
            <div class="seg">
              <strong><span class="segtitle">安装的程序：</span></strong> <span class="seg">bunzip2(→bzip2), bzcat(→bzip2), bzcmp, bzdiff, bzegrep, bzfgrep,
              bzgrep, bzip2, bzip2recover, bzless, bzmore</span>
            </div>
            <div class="seg">
              <strong><span class="segtitle">安装的库：</span></strong> <span class="seg">libbz2.{a,so}</span>
            </div>
          </div>
        </div>
        <div class="variablelist">
          <h3><a id="id3684394" name="id3684394"></a>简要描述</h3>
          <table border="0">
            <col align="left" valign="top" />
            <tbody>
              <tr>
                <td><a id="bunzip2" name="bunzip2"></a><span class="term"><span><strong class="command">bunzip2</strong></span></span></td>
                <td><p>解压使用 bzip2 压缩的文件</p></td>
              </tr>
              <tr>
                <td><a id="bzcat" name="bzcat"></a><span class="term"><span><strong class="command">bzcat</strong></span></span></td>
                <td><p>解压缩指定的文件到标准输出</p></td>
              </tr>
              <tr>
                <td><a id="bzcmp" name="bzcmp"></a><span class="term"><span><strong class="command">bzcmp</strong></span></span></td>
                <td><p>对 bzip2 压缩的文件运行 <span><strong class="command">cmp</strong></span> 命令</p></td>
              </tr>
              <tr>
                <td><a id="bzdiff" name="bzdiff"></a><span class="term"><span><strong class="command">bzdiff</strong></span></span></td>
                <td><p>对 bzip2 压缩的文件运行 <span><strong class="command">diff</strong></span> 命令</p></td>
              </tr>
              <tr>
                <td><a id="bzgrep" name="bzgrep"></a><span class="term"><span><strong class="command">bzgrep</strong></span></span></td>
                <td><p>对 bzip2 压缩的文件运行 <span><strong class="command">grep</strong></span> 命令</p></td>
              </tr>
              <tr>
                <td><a id="bzegrep" name="bzegrep"></a><span class="term"><span><strong class="command">bzegrep</strong></span></span></td>
                <td><p>对 bzip2 压缩的文件运行 <span><strong class="command">egrep</strong></span> 命令</p></td>
              </tr>
              <tr>
                <td><a id="bzfgrep" name="bzfgrep"></a><span class="term"><span><strong class="command">bzfgrep</strong></span></span></td>
                <td><p>对 bzip2 压缩的文件运行 <span><strong class="command">fgrep</strong></span> 命令</p></td>
              </tr>
              <tr>
                <td><a id="bzip2" name="bzip2"></a><span class="term"><span><strong class="command">bzip2</strong></span></span></td>
                <td><p>使用 Burrows-Wheeler 块排列文本压缩算法和霍夫曼编码来压缩文件。压缩比要大于 gzip 工具使用的基于"<span class="quote">Lempel-Ziv</span>"的压缩算法(如 <span><strong class="command">gzip</strong></span> 格式)，接近 PPM 统计压缩算法族的压缩比。</p></td>
              </tr>
              <tr>
                <td><a id="bzip2recover" name="bzip2recover"></a><span class="term"><span><strong class="command">bzip2recover</strong></span></span></td>
                <td><p>试图从被破坏的 bzip2 文件中恢复数据</p></td>
              </tr>
              <tr>
                <td><a id="bzless" name="bzless"></a><span class="term"><span><strong class="command">bzless</strong></span></span></td>
                <td><p>对 bzip2 压缩的文件运行 <span><strong class="command">less</strong></span> 命令</p></td>
              </tr>
              <tr>
                <td><a id="bzmore" name="bzmore"></a><span class="term"><span><strong class="command">bzmore</strong></span></span></td>
                <td><p>对 bzip2 压缩的文件运行 <span><strong class="command">more</strong></span> 命令</p></td>
              </tr>
              <tr>
                <td><a id="libbz2" name="libbz2"></a><span class="term"><tt class="filename">libbz2*</tt></span></td>
                <td><p>利用 Burrows-Wheeler 算法，实现无损块顺序数据压缩的库文件。</p></td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>
    <div class="navfooter">
      <ul>
        <li class="prev">
          <a accesskey="p" href="bash.html" title="Bash-3.1">后退</a>
          <p>Bash-3.1</p>
        </li>
        <li class="next">
          <a accesskey="n" href="diffutils.html" title="Diffutils-2.8.1">前进</a>
          <p>Diffutils-2.8.1</p>
        </li>
        <li class="up"><a accesskey="u" href="chapter06.html" title="第六章 安装系统基础软件">上一级</a></li>
        <li class="home"><a accesskey="h" href="../index.html" title="Linux From Scratch - 版本 6.2">首页</a>.
        </li>
      </ul>
    </div>
</body></html>
